﻿<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false"  CodeBehind="qst_manage_edit.aspx.cs" Inherits="Ccit.OA.Question.qst_manage_edit" %>
<%@ Register TagPrefix="ccit" Namespace="Ccit.ServerControls" Assembly="Ccit.ServerControls.ActionForm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>问卷管理-编辑问卷</title>
     <script language="javascript" type="text/javascript" src="../script/jquery.js"></script>
    <script language="javascript" type="text/javascript" src="../script/StringClass_Ext.js"></script>
    <script language="javascript" type="text/javascript" src="../script/jsonlib.js"></script>
    <script language="javascript" src="../script/jwindow.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jcontrol.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jbase64.js" type="text/javascript"></script>
    <script type="text/javascript">
          function doSelUser(vRagneId,vCtrlId,vCtrlName) {
                OpenRangeSelect(vRagneId,vCtrlId,vCtrlName,"1");
          }
          function CheckFrom()
          { 
               var title=$get("txtTitle").value; 
                if(title.Trim()=="")
                {
                    alert("尚未填写问卷标题!")
                    return false;
                } 
               var vEndTime =$get("txtEndtime").value; 
               if(vEndTime.Trim()!="")
                {
                    if(!vEndTime.IsDate())
                    {
                        alert("结束时间格式不正确!")
                        return false;
                    }
                    var mydate = new Date();
                    var month  = mydate.getMonth()+1;
                    var vTime = mydate.getYear()+"-"+month+"-"+mydate.getDate();
                    var msMes ={};
                    var check = compareDate(vEndTime,vTime)   
                    if(check==true)
                    {
                        alert("结束时间必须大于当前系统时间!")
                        return false;
                    }
                } 
              return true;
          }
          /* 判断起始日期大小 */
        function compareDate(DateOne,DateTwo)   
        {
            var OneMonth = DateOne.substring(5,DateOne.lastIndexOf ("-"));   
            var OneDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ("-")+1);   
            var OneYear = DateOne.substring(0,DateOne.indexOf ("-"));   
              
            var TwoMonth = DateTwo.substring(5,DateTwo.lastIndexOf ("-"));   
            var TwoDay = DateTwo.substring(DateTwo.length,DateTwo.lastIndexOf ("-")+1);   
            var TwoYear = DateTwo.substring(0,DateTwo.indexOf ("-"));   
              
            if (Date.parse(OneMonth+"/"+OneDay+"/"+OneYear) <=   
            Date.parse(TwoMonth+"/"+TwoDay+"/"+TwoYear))   
            {   
                return true;   
            }   
            else  
            {   
                return false;   
            } 
        }  
          function doSave(oType)
          {
            if(CheckFrom()==true)
            {
                 var msQuestion = {}; //消息对象
                 msQuestion.id=$get("_hidsRecid").value;
                 msQuestion.title=$get("txtTitle").value;
                 msQuestion.explain=$get("txtExplain").value;
                 msQuestion.rangemark=$get("_hidRangeMarkId").value;
                 msQuestion.range=$get("_hidRange").value;
                 msQuestion.pubrangemark=$get("_hidPUbRangeMarkId").value;
                 msQuestion.pubrange=$get("_hidPubRange").value;
                    var rbtn = new RadioList("radioType");
                    msQuestion.type = rbtn.checkedValue;
                 msQuestion.endtime = $get("txtEndtime").value;
                 var jsonExpr = JSON.stringify(msQuestion,function(key,value){return value;}); 
                      msQuestion = null;
                if(oType!="5")  
                {
                    PageMethods.DoSaveMes(jsonExpr,oType,ClientBack); 
                }
                else
                {
                    PageMethods.DoSaveMes(jsonExpr,oType,ClientCallBack); 
                }
             }   
          }
          function ClientBack(vResult)
          {
                eval("resultObj ="+vResult)
                if(resultObj.result!="-999")
                {
                    alert(resultObj.message);
                    switch(resultObj.ctrtype){
                         case "1":
                            $get("_hidsRecid").value = resultObj.result;
                            break;
                         case "2":
                          $get("_hidRecId").value = resultObj.result;
                            doClear();
                            break;
                         case "3":
                            doBack();
                            break;
                         case "4":                            
                            break;
                    }
                }
                else
                {
                    alert(resultObj.message)
                }
                resultObj = null;
          }
          function doClear()
          {
                $get("_hidsRecid").value = "0";
                $get("txtTitle").value="";
                $get("txtExplain").value="";
                $get("_hidPUbRangeMarkId").value="";
                $get("_hidPubRange").value="";
                $get("txtPubRange").value=""; 
                $get("_hidRangeMarkId").value="";
                $get("_hidRange").value="";
                $get("txtRanage").value="";
                $get("txtEndtime").value="";
          }
          function doBack()
          { 
                var TabId = $get("_hidTabId").value;
                var oPageParam="TABID="+TabId;
                var oEncodeParam=base64encode(oPageParam);
                var strURL = "qst_manage_index.aspx?"+oEncodeParam;
                document.location.href = strURL;
          }
          function doAdd()
          {
              var sRecid = $get("_hidRecId").value;
              if(sRecid=="0")
              {
                 doSave("5");
              }
              else
              {
                     AddInfo(sRecid);
              }
          }
          function AddInfo(sRecid)
          {  
                var oPageParam="QId="+sRecid;
                var oEncodeParam=base64encode(oPageParam);
                var strURL = "qst_manage_detail.aspx?"+oEncodeParam;
                OpenWindow(strURL,"","600","450");
          }
          function ClientCallBack(vResult)
          {
                eval("resultObj ="+vResult)
                if(resultObj.result!="-999")
                {
                    $get("_hidsRecid").value = resultObj.result;
                    $get("_hidRecId").value = resultObj.result;
                    var sRecId = $get("_hidRecId").value;
                    AddInfo(sRecId);
                }
          }
         //删除行
        function doRemoveRow(vTableName,vsRecid,vRowId)  
        {             
            var oType="4";
            var otable = document.getElementById(vTableName);
		    var oRowIndex = document.getElementById(vRowId).rowIndex;		        	        
		    if (confirm("删除当前行,是否继续?"))
		        PageMethods.DoOperate(vsRecid,oType,ClientBack); 
		        otable.deleteRow(oRowIndex);
        }
         /* FuncDesc:   上下移动用户显示顺序记录
         * FuncParam:  pUserId: 用户ID
         *             pType:   移动类型 0:上移; 1:下移 
         * FuncReturn: void
         */
        function doMove(pId,pOrder,pType) {
            PageMethods.ModeSingleStep(pId,pOrder,pType,ClientCBack);
        }
        function ClientCBack(vResult)
        {
            if(vResult!="-998")
            {
                if(vResult!="-999")
                {
                     __doPostBack("lnbQuery","");
                    return  true;
                }
            }           
        }
        function doEdit(vsRecId)
        {
            var sRecid = $get("_hidsRecid").value;
            var oPageParam="QId="+sRecid+"&Id="+vsRecId;
            var oEncodeParam=base64encode(oPageParam);
            var strURL = "qst_manage_detail.aspx?"+oEncodeParam;
            OpenWindow(strURL,"","600","500")
        }
        function DoBack()
        {
            __doPostBack("lnbQuery","");
        }
    </script>
</head>
<body>
    <ccit:ActionForm id="form1" runat="server">
    <asp:LinkButton ID="lnbQuery" CssClass="linktext" runat="server" 
                                 Visible="false" onclick="lnbQuery_Click" ></asp:LinkButton>
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager> 
     <input type="hidden" id="_hidTabId" runat ="server" />
   <input type="hidden" runat="server" id="_hidRecId" />
    <input type="hidden" id="_hidsRecid" runat="server" />
    <table class="tbToolbar" cellpadding="0" cellspacing="0" width="98%" align="center">
            <tr>
            <td width="2%" align="left">
                <div class="tbSeparator">
                </div>
            </td>
             <td class="titlebar" width="38%">                   
                 问卷管理-编辑问卷
            </td>
            <td align="right">               				 
					<nobr></nobr>            
            </td>
            <td align="right">
                <nobr>
            </td>            
          </tr>
         </table>
        <table cellpadding="0" class="tableborder" cellspacing="0" width="98%" align="center" id="tdMessage" runat="server">
            <tr>
			  <td  width="15%" height="14" align="right" class="pformleft"><nobr>问卷标题</nobr>			  </td>
				<td colspan="3" align="left" class="pformright">
				    <asp:TextBox  ID="txtTitle" Runat="server" CssClass="input" Width="98%"></asp:TextBox>			  				    </td>
			</tr>
			<tr> 
				<td width="15%" height="14" align="right" class="pformleft"><nobr>问卷说明</nobr>				</td>
				<td colspan="3" align="left" class="pformright">
				<asp:TextBox  ID="txtExplain" Runat="server" CssClass="input"   
                        Width="98%" TextMode="MultiLine" Height="60"></asp:TextBox>			  				    </td>
		    </tr>
			<tr>
				<td class="pformleft" align="right"><nobr>调查范围
				    <br />
                        <a href="javascript:doSelUser('_hidRangeMarkId','_hidRange','txtRanage')">
                            <img src="../images/toolbar/search.gif" border="0" /></a>                    
				</nobr>			  </td>
				<td colspan="3" align="left" class="pformright">
                    <nobr>
                    <input type="hidden" id="_hidRangeMarkId" runat="server" />
				    <input type="hidden" id="_hidRange" runat="server" />
                    <asp:TextBox ID="txtRanage" TextMode="MultiLine" Width="98%" Height="90px" 
                        runat="server" ReadOnly="true" CssClass="inputtext"></asp:TextBox>                    
                    </nobr>
				 </td>
			</tr>
			<tr>
				<td class="pformleft" align="right"><nobr>公布范围
				 <br />
                        <a href="javascript:doSelUser('_hidPUbRangeMarkId','_hidPubRange','txtPubRange')">
                            <img src="../images/toolbar/search.gif" border="0" /></a>      
				</nobr>			  </td>
				<td colspan="3" align="left" class="pformright">
                    <nobr>
                        <input type="hidden" id="_hidPUbRangeMarkId" runat="server" />
                        <input type="hidden" id="_hidPubRange" runat="server" />
                        <asp:TextBox ID="txtPubRange" TextMode="MultiLine" Width="98%" 
                        Height="70px" runat="server" ReadOnly="true" CssClass="inputtext"></asp:TextBox>
				    </nobr>		
			   </td>
			</tr>
			<tr>
				<td class="pformleft" align="right"><nobr>填报类型</nobr>			  </td>
				<td width="35%" align="left" class="pformrightline" valign="top">			    
                    <asp:RadioButtonList ID="radioType" runat="server" Height="16px" 
                        RepeatDirection="Horizontal" Width="158px">
                        <asp:ListItem Value="0" >匿名</asp:ListItem>
                        <asp:ListItem Value="1" Selected>实名</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
				<td class="pformleft" align="center" width="11%">截止时间</td>
				<td class="pformright" align="left" width="39%"><nobr>	
				    <asp:TextBox  ID="txtEndtime" Runat="server" CssClass="input" Width="60%"></asp:TextBox>  	
				    <IMG class="getdate" id="IMG4" title="选择日期" src="../images/toolbar/Calendar.gif" relaobj="txtEndtime">	</nobr>			 			    
				</td>
			</tr> 
         </table>
         <table runat="server" cellpadding="0" cellspacing="0" width="98%" align="center" >
            <tr>
                <td colspan="2">
                </td>
           </tr>
            <tr>
                <td align="left" width="70%">
                  >>问题列表
                </td>  
                <td align="right">
                <nobr>　
                     <a  id="lnbAdd" Runat="server" class="linktext"  
                                href="javascript:doAdd()">
							        <img src="../images/toolbar/new.gif" border="0">
				    </a>
			　　</nobr>            
            </td>               
            </tr>            
         </table>
         <table  id="tbProduct"  runat="server" cellpadding="0" cellspacing="0" width="98%" align="center" >
            <tr id="row_0"  class="listtitle"> 
                <td width="30%" align="center" class="listcelltitle">问题描述</td>
                <td width="8%" align="center" class="listcelltitle">选项类型</td>
                <td width="10%" align="center" class="listcelltitle">其他意见</td>            
                <td width="28%" align="center" class="listcelltitle">选项</td>
                <td width="10%" align="center" class="listcelltitle">显示顺序</td>
                <td width="12%" align="center" class="listcelltitle">操作</td>
           </tr> 
         </table>
      <table  width="98%" height="20" align="center" cellpadding="0" cellspacing="0"     runat="server">
         <tr class="pformstrip" height="20">
           <td colspan="4" align="center">
                <input type="button" id="btnSave" value="保存" class="button" onclick="doSave('1')" />
                &nbsp;
                <input type="button" id="btnSaveCont" value="保存并新增" class="button" onclick="doSave('2')" />
                &nbsp;
                <input type="button" id="btnSaveBack" value="保存并返回" class="button" onclick="doSave('3')" />
                &nbsp;  
                <input type="button" id="btnBack" value="返回" class="button" onclick="doBack()" />
                &nbsp;
            </td>
        </tr>
    </table>
    </ccit:ActionForm>
    
</body>
</html>
